package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.UmsResourceCategory;
import com.itheima.mapper.UmsResourceCategoryMapper;
import com.itheima.service.UmsResourceCategoryService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 资源分类表 服务实现类
 * </p>
 *
 * @author zhuguo
 * @since 2022-11-10
 */
@DubboService
public class UmsResourceCategoryServiceImpl extends ServiceImpl<UmsResourceCategoryMapper, UmsResourceCategory> implements UmsResourceCategoryService {
    @Autowired
    private UmsResourceCategoryMapper umsResourceCategoryMapper;


    @Override
    public List<UmsResourceCategory> getAll() {
        return umsResourceCategoryMapper.getAll();
    }

    @Override
    public void create(UmsResourceCategory category) {
        // category.setCreateTime(LocalDateTime.now());
        umsResourceCategoryMapper.insert(category);
    }

    @Override
    public void deleteCategoryById(Integer id) {
        umsResourceCategoryMapper.deleteById(id);
    }

    @Override
    public void updateCategoryById(Integer id, UmsResourceCategory resourceCategory) {
        LambdaQueryWrapper<UmsResourceCategory> lqw = new LambdaQueryWrapper<>();
        lqw.eq(UmsResourceCategory::getId, id);
        umsResourceCategoryMapper.update(resourceCategory, lqw);
    }
}
